<?php  

/**
* 
*/
class Widget
{
  protected $_name;
  protected $_value;
  protected $_form;
  protected $_file;
  protected $_widgetName;
  
  protected $_widgetObject;
  protected $_woClass='miho.form.WidgetObject';
  
  public function getWO(){
    return $this->_widgetObject;
  }
  
  public function __construct($name)
  {
    $this->_initialize();
    $this->_widgetObject->setName($name);
  }
  
  protected function _initialize(){
    $this->_initializeWO();
  }
  
  protected function _initializeWO(){
    import($this->_woClass);
    $class = ClassLoader::getInstance()->guessClassName($this->_woClass);
    $this->_widgetObject = new $class();
  }
  
  public function getViewPath(){
    return realpath(dirname($this->_file).'/view');
  }
  
  public function render(){
    $view = View::getInstance();
    return $view->renderPartial($this->getViewPath().'/_'.$this->_widgetName.'Widget',array('wo'=>$this->getWO()));
  }
  
  public function __toString(){
    return $this->render();
  }
  
}


?>